﻿
using RTW.DAL;
using RTW.OA.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RTW.OA.Areas.Meeting.Servers
{
    public class MeetingRuleServers
    {
        private readonly IRepository<meeting_rule> meeting_ruleRepository;

        public MeetingRuleServers()
        {
            meeting_ruleRepository = new DapperRepository<meeting_rule>();

        }

        public List<meeting_rule> GetData()
        {
            var datas = meeting_ruleRepository.GetAllEnumerable();

            return datas.ToList();
        }

        public meeting_rule GetModelById(string id)
        {
            return meeting_ruleRepository.GetById(id);
        }


        internal void Add(meeting_rule model)
        {
            meeting_ruleRepository.Insert(model);
        }

        internal void Update(meeting_rule model)
        {
            meeting_ruleRepository.Update(model);
        }

        internal void Del(string id)
        {
            meeting_ruleRepository.DeleteByIds(id);
        }


        internal List<SelectListItem> GetMEETING_OPERATOR()
        {
            List<SelectListItem> tables = new List<SelectListItem>();
            var dstable = meeting_ruleRepository.SqlWithParamsDynamic("select [USER_ID] Value,[USER_NAME] Text from [dbo].[users]");
            tables.Clear();

            foreach (var dr in dstable)
            {
                string Id = dr.Value.ToString();
                string Title = dr.Text.ToString().Trim();
                tables.Add(new SelectListItem { Value = Id, Text = Title });
            }

            return tables;
        }


    }
}